package com.sportschain.app.shop.widget;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.sportschain.app.R;
import com.sportschain.app.core.image.BannerImageLoader;
import com.sportschain.app.shop.activity.ActListActivity;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author LYZ 2019.01.12
 */
public class ShopHeaderViewWrapper {


    @BindView(R.id.banner_view)
    Banner mBannerView;
    @BindView(R.id.store_act_ll)
    LinearLayout mStoreActLl;
    @BindView(R.id.union_act_ll)
    LinearLayout mUnionActLl;

    private Context mContext;
    private View mRootView;

    public ShopHeaderViewWrapper(Context context) {
        mContext = context;
        initView();
        initData();
    }

    private void initView() {
        mRootView = LayoutInflater.from(mContext).inflate(R.layout.header_shop, null);
        ButterKnife.bind(this, mRootView);

        mBannerView.setImageLoader(new BannerImageLoader());
        mBannerView.setIndicatorGravity(BannerConfig.CENTER);
    }

    private void initData() {
        List<Integer> images = new ArrayList<>();
        images.add(R.drawable.temp_cover);
        images.add(R.drawable.temp_cover);
        images.add(R.drawable.temp_cover);
        images.add(R.drawable.temp_cover);
        mBannerView.setImages(images);
        mBannerView.start();
    }

    @OnClick({R.id.store_act_ll, R.id.union_act_ll})
    public void onClick(View view) {
        Intent intent = new Intent(mContext, ActListActivity.class);

        switch (view.getId()) {
            case R.id.store_act_ll:
                intent.putExtra("mode", ActListActivity.MODE_STORE);
                mContext.startActivity(intent);
                break;
            case R.id.union_act_ll:
                intent.putExtra("mode", ActListActivity.MODE_UNION);
                mContext.startActivity(intent);
                break;
        }
    }

    public View getView() {
        return mRootView;
    }
}
